/*
 * @Author: laladuduqq
 * @Date: 2024-12-22 17:10:44
 * @LastEditors: laladuduqq
 * @LastEditTime: 2024-12-22 17:11:03
 */
#ifndef __SIGNAL_CREATE_H
#define __SIGNAL_CREATE_H

#include "rtthread.h"

// 定义线性运动参数
typedef struct {
    float start_angle;  // 起始角度
    float end_angle;    // 结束角度
    float period;       // 周期 (单位: ms)
} SinusoidalMotionParams;

typedef struct {
    float min_position;
    float max_position;
    float frequency;
    float direction;
    float start_time;
    rt_bool_t is_moving;
    float current_position;
} LinearMotionParams_t;


typedef struct {
    float min_position;
    float max_position;
    float frequency; // 正弦波的频率
    float start_time;
    int is_moving;
    float current_position;
} SinusoidalMotionParams_t;

void LinearMotionInit(LinearMotionParams_t *params, float min_pos, float max_pos);
float LinearMotionUpdate(LinearMotionParams_t *params);
void LinearMotionStart(LinearMotionParams_t *params, float current_position);
void LinearMotionStop(LinearMotionParams_t *params);

void SinusoidalMotionInit(SinusoidalMotionParams_t *params, float min_pos, float max_pos, float frequency);
float SinusoidalMotionUpdate(SinusoidalMotionParams_t *params);
void SinusoidalMotionStart(SinusoidalMotionParams_t *params, float current_position);
void SinusoidalMotionStop(SinusoidalMotionParams_t *params);

float generate_sine_wave(float time);

float calculate_sinusoidal_motion(SinusoidalMotionParams params, rt_tick_t current_tick);

float GenerateSinWave(float amplitude, float offset, float period);

float GenerateStepWave(float a0, float a1, float t0);

float GenerateRampWave(float a0, float a1, float t0, float t1);

float GeneratePulseWave(float a1, float a2, float t1, float t2);

float GenerateSawtoothWave(float a0, float a1, float T);

#endif